//
//  RootViewController.m
//  ManagementByObjectives
//
//  Created by 寺田 篤史 on 11/09/22.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "RootViewController.h"
#import "SqliteDB.h"
#import "ManagementDataModel.h"

@implementation RootViewController

- (id)init {
    self.title = NSLocalizedString(@"rootTitle", "rootTitle is top page");

    /* DB setting
    SqliteDB *db = [[SqliteDB alloc]init];
    [db initializeDatabaseIfNeeded];
    
    ManagementDataModel* account = [ManagementDataModel selectById:1];
    DLog("account=%@",account);
    NSString *username = [account userName];
    DLog("username=%@",username);
    */
    
    //ナビゲーションバーにボタンを追加
    UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
                               initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
                               target:self
                               action:@selector(add:)
                               ];
    self.navigationItem.rightBarButtonItem = addButton;
    
    UIBarButtonItem *historyButton = [[UIBarButtonItem alloc]
                                    initWithTitle:NSLocalizedString(@"historyButton", "historyButton go to history page")
                                    style:UIBarButtonItemStyleBordered 
                                    target:self 
                                    action:@selector(history:)
                                    ];
    self.navigationItem.leftBarButtonItem = historyButton;
    
    //Table:management_objectを判定し、登録データをテーブルで表示
                    
    return self;
}

-(void)add:(id)sender{
    //addItemViewController *add=[[[addItemViewController alloc] init];
    //                            [self.navigationController pushViewController:add animated:YES];
}
-(void)history:(id)sender{
    //addItemViewController *add=[[[addItemViewController alloc] init];
    //                            [self.navigationController pushViewController:add animated:YES];
}
@end
